import { PropsWithChildren } from 'react';

import { urlComponents } from '@/shared/constants/stores';
import { innerUrls, urls } from '@/shared/constants/urls';
import { Button, ButtonVariants } from '@/shared/ui/Button';
import cn from 'classnames';
import dayjs from 'dayjs';

import cs from './Footer.module.scss';

type FooterProps = {
  className?: string;
} & PropsWithChildren;

export const Footer = ({ children, className }: FooterProps) => (
  <footer className={cn('footer', cs.block, className)}>
    <div className={cs.container}>
      <div className={cs.text}>
        <span>© 2021–{dayjs().year() < 2024 ? 2024 : dayjs().year()}</span>
        <span>Приложение&nbsp;«companyName&nbsp;—&nbsp;первый&nbsp;прикорм» носит рекомендательный характер</span>
        <Button href={innerUrls.agreement} link target="_blank">
          Пользовательское соглашение
        </Button>
      </div>
      <div className={cs.links}>
        {Object.entries(urlComponents).map(([url, component]) => (
          <Button
            aria-label={url}
            className={cn(cs.linkButton, { [cs.appleIcon]: url === 'appStore' })}
            href={urls[url as keyof typeof urls]}
            key={url}
            link
            variant={ButtonVariants.Secondary}
          >
            {component}
          </Button>
        ))}
      </div>
      {children}
    </div>
  </footer>
);
